@include('admin.header')

<style type="text/css">
  .opartion {
    width: 350px;
  }

  .pagination {
    list-style: none;
    float: right;
  }

  .pagination li {
    float: left;
    padding-left: 5px;
    padding-right: 5px;
  }

  .input_search {
    margin-top: 10px;
  }
</style>

<div class="wrap">
  <div class="margin-bottom-20">
    {{ csrf_field() }}
    <input id="change_url" value="" type="hidden"/>
    <form action="{{url('wallet/wallet_list')}}" method="post">
        <div class="cl pd-5 bg-1 bk-gray mt-20">
         拥有者账号：
       <input type="text" style="width: 200px;height: 35px;" name="nodecode" value="{{$nodecode or ''}}"/>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       
         拥有者姓名：
       <input type="text" style="width: 200px;height: 35px;" name="nodename" value="{{$nodename or ''}}"/>
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        钱包编号：
       <input type="text" style="width: 200px;height: 35px;" name="purseid" value="{{$purseid or ''}}"/>
      
        <br/>

        拥有者类型：
        <select name="ownertype" style="width: 120px;">
          <option value=''>--请选择--</option>
          <option value='0_None'  @if($ownertype=='None'){echo selected="selected";} @endif>None</option>
          <option value='1_用户账户'  @if($ownertype=='用户账户'){echo selected="selected";} @endif>用户账户</option>
          <option value='2_商家账户'  @if($ownertype=='商家账户'){echo selected="selected";} @endif>商家账户</option>
          <option value='3_企业账户'  @if($ownertype=='企业账户'){echo selected="selected";} @endif>企业账户</option>
          <option value='99_系统账户'  @if($ownertype=='系统账户'){echo selected="selected";} @endif>系统账户</option>
        </select>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         钱包类型：
        <select name="pursetype" style="width: 120px;">
          <option value=''>--请选择--</option>
          <option value='0_None' @if($pursetype=='None'){echo selected="selected";} @endif>None</option>
          <option value='1_收益账户' @if($pursetype=='收益账户'){echo selected="selected";} @endif>收益账户</option>
          <option value='2_现金账户' @if($pursetype=='现金账户'){echo selected="selected";} @endif>现金账户</option>
          <option value='3_积分账户' @if($pursetype=='积分账户'){echo selected="selected";} @endif>积分账户</option>
          <option value='4_o2o收益账户' @if($pursetype=='o2o收益账户'){echo selected="selected";} @endif>o2o收益账户</option>
          <option value='96_过账账户' @if($pursetype=='过账账户'){echo selected="selected";} @endif>过账账户</option>
          <option value='97_授信账户' @if($pursetype=='授信账户'){echo selected="selected";} @endif>授信账户</option>
          <option value='98_中央银行账户' @if($pursetype=='中央银行账户'){echo selected="selected";} @endif>中央银行账户</option>
          <option value='99_系统收益账户' @if($pursetype=='系统收益账户'){echo selected="selected";} @endif>系统收益账户</option>
        </select>


          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <span class="text-c">
            <button name="" id="search" class="btn btn-success user_search" type="
            submit"><i class="Hui-iconfont"></i> 搜索</button>
            </span>
            <span class="r">共有数据：<strong>{{$data->total()}}</strong> 条</span>
        </div>
    </form>
  </div>
  <form class="form-horizontal js-ajax-form" method="post" novalidate="novalidate">
    <table class="table table-hover table-bordered">
      <thead>
      <tr>
        <th>账户编号</th>
        <th>拥有者类型 </th>
        <th>拥有者编号 </th>
        <th>拥有者账号</th>
        <th>拥有者姓名</th>
        <th>账户类型</th>
        <th>子账户编号</th>
        <th>账号余额</th>
        <th>最小金额</th>
        <th>冻结金额</th> 
        <th>可用金额</th> 
        <th>货币单位</th>
        <th>创建时间</th>
      </tr>
      </thead>
      <tbody>
      @foreach($data as $val)
      <tr>
        <td>{{$val->purseid}}</td>
        <td>
          @if($val->ownertype == 0)
              <span>None</span>
          @elseif($val->ownertype == 1)
              <span>用户账户</span>
          @elseif($val->ownertype == 2)
              <span>商家账户</span>
          @elseif($val->ownertype == 3)
              <span>企业账户</span>
          @else
              <span>系统账户</span>    
          @endif
        </td>
        <td>{{$val->ownerid}}</td>
        <td>{{$val->nodecode}}</td>
        <td>{{$val->nodename}}</td>

        <td>
          @if($val->pursetype == 0)
              <span>None</span>
          @elseif($val->pursetype == 1)
              <span>收益账户</span>
          @elseif($val->pursetype == 2)
              <span>现金账户</span>
          @elseif($val->pursetype == 3)
              <span>积分账户</span>
          @elseif($val->pursetype == 4)
              <span>o2o收益账户</span>    
          @elseif($val->pursetype == 96)
              <span>过账账户</span>    
          @elseif($val->pursetype == 97)
              <span>授信账户</span>    
          @elseif($val->pursetype == 98)
              <span>中央银行账户</span>            
          @else
              <span>系统收益账户</span>    
          @endif
        </td>

        <td>{{$val->subid}}</td>
         <td style="color:red;">{{$val->balance}}</td>
         <td>{{$val->minvalue}}</td>
         <td>{{$val->freezevalue}}</td>
         <td>{{$val->balance}}</td>
         <td>{{$val->currency_unit}}</td>
         <td>{{$val->create_time}}</td>
      </tr>
      @endforeach
      </tbody>
    </table>
   <input type="hidden"  class="checkVal" value=""> 
   <input type="hidden"  class="checkVal2" value=""> 
   <input type="hidden"  class="checkVal3" value=""> 
   <input type="hidden"  class="checkVal4" value=""> 
   <input type="hidden"  class="checkVal5" value=""> 
   <input type="hidden"  class="checkVal6" value=""> 
   <input type="hidden"  class="checkVal7" value=""> 
   <input type="hidden"  class="checkVal8" value=""> 
   <input type="hidden"  class="checkVal9" value=""> 
   <input type="hidden"  class="checkVal10" value=""> 
   <input type="hidden"  class="checkVal11" value=""> 
   <input type="hidden"  class="checkVal12" value=""> 
   <input type="hidden"  class="checkVal13" value=""> 
  <input type="submit" class="btn btn-primary" value="确定" />
    <!-- 分页 -->
    @if (!empty($data))
    <div class="page_list">
        {{$data->links()}}
    </div>
    @endif
  </form>
</div>
<script>
$(function(){



  $("table tr").click(function() {//为表格的行添加点击事件
     var tr = $(this);//找到tr原色
     var td = tr.find("td");//找到td元素
     var checkVal = td[0].innerHTML;
     var checkVal2 = removeHTMLTag(td[1].innerHTML);
     var checkVal3 = td[2].innerHTML;
     var checkVal4 = td[3].innerHTML;
     var checkVal5 = td[4].innerHTML;
     var checkVal6 = removeHTMLTag(td[5].innerHTML);
     var checkVal7 = td[6].innerHTML;
     var checkVal8 = td[7].innerHTML;
     var checkVal9 = td[8].innerHTML;
     var checkVal10 = td[9].innerHTML;
     var checkVal11 =td[10].innerHTML;
     var checkVal12 = removeHTMLTag(td[11].innerHTML);
     var checkVal13= td[12].innerHTML;
     $('.checkVal').val(checkVal);
     $('.checkVal2').val(checkVal2);
     $('.checkVal3').val(checkVal3);
     $('.checkVal4').val(checkVal4);
     $('.checkVal5').val(checkVal5);
     $('.checkVal6').val(checkVal6);
     $('.checkVal7').val(checkVal7);
     $('.checkVal8').val(checkVal8);
     $('.checkVal9').val(checkVal9);
     $('.checkVal10').val(checkVal10);
     $('.checkVal11').val(checkVal11);
     $('.checkVal12').val(checkVal12);
     $('.checkVal13').val(checkVal13);
    tr.css('background-color','red').siblings().css('background-color','#FFFFFF');
    //$("table tr").css('background-color','#FFFFFF');//先将颜色改为以前面的颜色
    ///$(this).css('background-color','red');//再将单击的那行改成需要的颜色
    // $("table tr").css('background-color','transparent');
    // $(this).css('background-color','red');
  })
  $('.btn-primary').click(function(){
    var checkID = $('.checkVal').val();
    var checkusertype = $('.checkVal2').val();
    var checkbianhao = $('.checkVal3').val();
    var checknamecode = $('.checkVal4').val();
    var checknamename = $('.checkVal5').val();
    var checkzhanghutype = $('.checkVal6').val();
    var zizhanghubianhao = $('.checkVal7').val();
    var zhanghuyue = $('.checkVal8').val();
    var minamont = $('.checkVal9').val();
    var dongjie = $('.checkVal10').val();
    var keyong = $('.checkVal11').val();
    var huobidanwei = $('.checkVal12').val();
    var createtime = $('.checkVal13').val();
     parent.$("#purseid").val(checkID);
     parent.$("#pursetypeName").val(checkusertype);
     parent.$("#bianhao").val(checkbianhao);
     parent.$("#unodecode").val(checknamecode);
     parent.$("#unodename").val(checknamename);
     parent.$("#zhanghutype").val(checkzhanghutype);
     parent.$("#zizhanghu").val(zizhanghubianhao);
     parent.$("#zhanghuyu").val(zhanghuyue);
     parent.$("#minyue").val(minamont);
     parent.$("#dongjieyue").val(dongjie);
     parent.$("#keyongyu").val(keyong);
     parent.$("#huobidanww").val(huobidanwei);
     parent.$("#ctime").val(createtime);










      // $.ajax({
      //   type: "POST",
      //   url: "{{url('capital/account_transfer')}}",
      //   data: {'id':checkID},
      //   success: function(msg){
      //      // window.parent.location.reload();
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
      //   }
      // });

  });

});

function removeHTMLTag(str) {
            str = str.replace(/<\/?[^>]*>/g,''); //去除HTML tag
            str = str.replace(/[ | ]*\n/g,'\n'); //去除行尾空白
            //str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
            str=str.replace(/ /ig,'');//去掉 
            return str;
    }
</script>
